#ifndef _LCD_CTRL_H_INCLUDE_
#define _LCD_CTRL_H_INCLUDE_

#define LCM_SUCCESS           0
#define LCM_FAILURE           -1
#define LCM_ERR_MEM_ALLOC     -2

#define DISPMSG(cond,printf_exp)	 \
   (NKDbgPrintfW(TEXT("[HiDisplay|%s] "),TEXT(__FUNCTION__)),(NKDbgPrintfW printf_exp))

typedef enum 
{
  LCDCONTROL_DISABLE_CLCDC = 0,
  LCDCONTROL_ENABLE_CLCDC 
}LCDSWITCH;


typedef struct 
{
    int screenWidth;
    int screenHeight;
    int screenBpp;
    int screenFrequency;
}LCMPanelInfo;

/*
 * Define CLCDC driver registers
 */
typedef volatile struct _CLCDC_BASE_REG
{
    DWORD    LCDTIMING_0_R;
    DWORD    LCDTIMING_1_R;
    DWORD    LCDTIMING_2_R;
    DWORD    LCDTIMING_3_R;
    DWORD    LCDUPBASE_R;
    DWORD    LCDLPBASE_R;
    DWORD    LCDIMSC_R;
    DWORD    LCDCONTROL_R;
    DWORD    LCDRIS_R;
    DWORD    LCDMIS_R;
    DWORD    LCDICR_R;
    DWORD    LCDUPCURR_R;
    DWORD    LCDLPCURR_R;
    DWORD    LCDPALETTE_R;

    
}CLCDC_REG, *P_CLCDC_REG;
/*
 * Define LCD driver registers
 */
typedef struct _LCD_BASE_REG
{
    volatile DWORD*    pLcmGpio10Reg;
    
    P_CLCDC_REG        pClcdcReg;

    /*define LCD display related parameters*/
    DWORD              ulDispScreenWidth;
    DWORD              ulDispScreenHeight;
    INT32              ulDispBpp;
    DWORD              ulFrameBufferSize;      
}LCD_REG, *P_LCD_REG;

class CLCMCtrl
{
public:
    CLCMCtrl(unsigned long clcdcRegBaseVa, unsigned long  videoSramBaseVa);
    //LCM initialize
    virtual void DispInitialize(void);
    //LCM sleep routine
    virtual int LCMSleepIn(void);
    //LCM wakeup routine
    virtual int LCMSleepOut(void);
    //LCM query info
    virtual int LCMQueryInfo(LCMPanelInfo * lcmInfo) = 0;
    //LDI initialize
    virtual int LDIInit(void);
    // SPI power control
    virtual int SspPowerSwitch(bool bPowerOn);

    //create a new instance of LCM Panel
    static CLCMCtrl *LCM_New(unsigned long clcdcRegBaseVa, unsigned long  videoSramBaseVa );
    virtual ~CLCMCtrl()
    {
    }
    
protected:    
    int ClcdcEnable(P_LCD_REG pLcdReg, LCDSWITCH bEnable);
    int LcmReset(P_LCD_REG pLcdReg);

    //methods impl by derived class
    virtual int LcmInit(void) = 0 ;
    virtual int LcmPowerOff(void) = 0;
    virtual int ClcdcInit(P_LCD_REG pLcdReg) = 0;

private:
    unsigned long m_clcdcRegBaseVa;
    unsigned long m_videoSramBaseVa;
};
#endif